
/*
 * GET Login page.
 */
exports.Login = function(req, res){
	
  res.render('home/login', { title: "Login" });
};


var userManager = require('../common/UserManager');
/*
 * Post LoginAth
 */
exports.LoginAth = function(req, res){

	var query = {name: req.body.name, password: req.body.password};

	console.log("name: "+query.name + " %%%% password: " + query.password);

	userManager.LoginAth(query, function(flag){
		if(flag){
			var user = { 'username': query.name };
			console.log('session======'+req.session);
			req.session.user = user;

			res.render('home', { title: 'Noke ERP', menusno: 1001 });
		}else{
			
			req.session.user = null;
			res.redirect('/login');
		}

	});
};

/*
 * GET home page.
 */
exports.Index = function(req, res){
	
  res.render('home', { title: 'Noke ERP', menusno: 1001 });
};


/*
 * GET FreightTiered listing.
 */
exports.FreightTiered = function (req, res) {
    res.render('home/FreightTiered', { title:'Freight Tiered', menusno: 10030001 });
};

/*
 * GET Editormd page.
 */
exports.Editormd = function(req, res){
  res.render('home/Editormd', { title: 'Editormd', menusno: 1004 });
};

/*
 * Save Editormd.
 * Post
 */
exports.SaveEditormd = function(req, res){
 	var md = require('./editormd');
 	md.Save(req, res, function(result){
 		res.send(result);
 	});
};